/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.store;

import java.sql.Date;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import oracle.jdbc.OracleTypes;
import queenb.net.datacontrol.DataStatement;
import queenb.net.datacontrol.Param;
import queenb.net.entitybean.N450;
import queenb.web.util.PackageContants;

/**
 *
 * @author Nguyen Hung
 */
public class N450Store extends N450 {
    public List<N450> findAllN450ForCombo(int pnFH000, int pnFH200, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.LIST_COMBTABN450, OracleTypes.CURSOR, new Param[]{
                       new Param(OracleTypes.INTEGER, pnFH000),
                       new Param(OracleTypes.INTEGER, pnFH200),
                       new Param(OracleTypes.CHAR, pvLOGIN)
                   });
           return super.find(dataStatement, N450.class);
        } catch (SQLException ex) {
            Logger.getLogger(N450Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(N450Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(N450Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public int updateN450(int pnPN450, String pvNV451, String pvNV452, String pvNV453, int pnFH000, int pnFH200, String pvLOGIN) {
        try {
            DataStatement updateStatement = new DataStatement(PackageContants.UPDATE_N450, OracleTypes.INTEGER, new Param[]{
                        new Param(OracleTypes.INTEGER, pnPN450),
                        new Param(OracleTypes.CHAR, pvNV451),
                        new Param(OracleTypes.CHAR, pvNV452),
                        new Param(OracleTypes.CHAR, pvNV453),
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.CHAR, pvLOGIN)});
            return super.update(updateStatement, N450.class);
        } catch (SQLException ex) {
            Logger.getLogger(N450Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }

    }

    public List<N450> getListN450(int pnFH000, int pnFH200, String pvLOGIN) throws SQLException, InstantiationException, IllegalAccessException {
        DataStatement dataStatement = new DataStatement(PackageContants.LIST_N450, OracleTypes.CURSOR, new Param[]{
                    new Param(OracleTypes.INTEGER, pnFH000),
                    new Param(OracleTypes.INTEGER, pnFH200),
                    new Param(OracleTypes.CHAR, pvLOGIN)
                });
        return super.find(dataStatement, N450.class);
    }

    public int updateN450i(int pnFN450, int pnFN850, String pvNV852, String pvNV303, Date pdND304, Date pdND305, String pvLOGIN) {
        DataStatement updateN900Statement = new DataStatement(PackageContants.UPDATE_N300, OracleTypes.INTEGER, new Param[]{
                    new Param(OracleTypes.INTEGER, pnFN450),
                    new Param(OracleTypes.INTEGER, pnFN850),
                    new Param(OracleTypes.CHAR, pvNV852),
                    new Param(OracleTypes.CHAR, pvNV303),
                    new Param(OracleTypes.DATE, pdND304),
                    new Param(OracleTypes.DATE, pdND305),
                    new Param(OracleTypes.CHAR, pvLOGIN)});
        try {
            return super.update(updateN900Statement, null);
        } catch (SQLException ex) {
            Logger.getLogger(N450Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }

    }

    public int deleteN300(int pnFN850, int pnFN450, String pvLOGIN) {
        DataStatement deleteN900Statement = new DataStatement(PackageContants.DELETE_N300, OracleTypes.INTEGER, new Param[]{
                    new Param(OracleTypes.INTEGER, pnFN850),
                    new Param(OracleTypes.INTEGER, pnFN450),
                    new Param(OracleTypes.CHAR, pvLOGIN)
                });
        try {
            return super.update(deleteN900Statement, null);
        } catch (SQLException ex) {
            Logger.getLogger(N300Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }
    }
    
    public int deleteN450(int pnPN450, String pvLOGIN) {
         DataStatement dataStatement = new DataStatement(PackageContants.DELETE_N450, OracleTypes.INTEGER, new Param[]{
                    new Param(OracleTypes.INTEGER, pnPN450),
                    new Param(OracleTypes.CHAR, pvLOGIN)});
        try {
            return super.update(dataStatement, N450.class);
        } catch (SQLException ex) {
            Logger.getLogger(N450Store.class.getName()).log(Level.SEVERE, null, ex);
            return 0;
        }

    }
}
